package com.example.motion.exception;

import com.example.motion.config.ResultT;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理
 *
 * @author jxf
 * @version 1.0.0
 * @since 1.0.0
 */
@RestControllerAdvice
public class SysRuntimeExceptionHandler {

    @ExceptionHandler(TokenRuntimeException.class)
    public ResultT tokenRuntimeException(TokenRuntimeException e) {
        e.printStackTrace();
        return ResultT.error(e.getCode(), e.getMsg());
    }

    @ExceptionHandler(Exception.class)
    public ResultT handlerException(Exception e) {
        e.printStackTrace();
        return ResultT.error();
    }
}